﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefRoute" :model="stateRoute.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_RouteCode_FormItem" prop="Entity.RouteCode" :label="$t('message.autotrans._Model_Route_RouteCode')">
            <el-input v-model="stateRoute.vmModel.Entity.RouteCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_RouteName_FormItem" prop="Entity.RouteName" :label="$t('message.autotrans._Model_Route_RouteName')">
            <el-input v-model="stateRoute.vmModel.Entity.RouteName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_RouteVersion_FormItem" prop="Entity.RouteVersion" :label="$t('message.autotrans._Model_Route_RouteVersion')">
            <el-input v-model="stateRoute.vmModel.Entity.RouteVersion" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductCode_FormItem" prop="Entity.ProductCode" :label="$t('message.autotrans._Model_Route_ProductCode')">
            <el-input v-model="stateRoute.vmModel.Entity.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field2_FormItem" prop="Entity.Field2" :label="$t('message.autotrans._Model_Route_Field2')">
            <el-input v-model="stateRoute.vmModel.Entity.Field2" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field3_FormItem" prop="Entity.Field3" :label="$t('message.autotrans._Model_Route_Field3')">
            <el-input v-model="stateRoute.vmModel.Entity.Field3" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field4_FormItem" prop="Entity.Field4" :label="$t('message.autotrans._Model_Route_Field4')">
            <el-input v-model="stateRoute.vmModel.Entity.Field4" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field5_FormItem" prop="Entity.Field5" :label="$t('message.autotrans._Model_Route_Field5')">
            <el-input v-model="stateRoute.vmModel.Entity.Field5" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitRoute"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseRoute"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationRouteCreate;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { routeApi } from '/@/api/baseinformation/route';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefRoute = ref();
const stateRoute = reactive({
    vmModel: {
	  Entity:{
        RouteCode: '',
        RouteName: '',
        RouteVersion: '',
        ProductCode: '',
        Field2: '',
        Field3: '',
        Field4: '',
        Field5: '',
      },

	},
    
});

// 取消
const onCloseRoute = () => {
    closeDialog();
};

// 提交
const onSubmitRoute = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefRoute.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            routeApi().add(stateRoute.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

